import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    username: '',
    isLoggedIn: false,
    token: '' // 添加token状态
  }),
  actions: {
    login(username: string, token: string) {
      this.username = username
      this.isLoggedIn = true
      this.token = token // 存储token
    },
    logout() {
      this.username = ''
      this.isLoggedIn = false
      this.token = '' // 清除token
    }
  }
})